package cn.com.xf.dao.impl;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import cn.com.xf.dao.TblDestinationDAO;
import cn.com.xf.dao.support.XFSqlMapClientDaoSupport;
import cn.com.xf.domain.TblDestination;

@Repository
public class TblDestinationDAOImpl extends XFSqlMapClientDaoSupport implements TblDestinationDAO{
	
	public TblDestinationDAOImpl() {
		super();
	}
	public TblDestination selectCodeid(String codeid){		
		return (TblDestination) getSqlMapClientTemplate().queryForObject("TBL_OA_DESTINATION.selectCodeid", codeid);
		
	}
	public int countCodeid(String codeid) {
		int count= (Integer) getSqlMapClientTemplate().queryForObject(
				"TBL_OA_DESTINATION.countCodeid", codeid);
		return count;
	}

	public TblDestination selectById(Integer id) {
		TblDestination key = new TblDestination();
		key.setId(id);
		TblDestination dest = (TblDestination) getSqlMapClientTemplate().queryForObject(
				"TBL_OA_DESTINATION.selectById", key);
		return dest;
	}

	public int deleteById(Integer id) {
		TblDestination key = new TblDestination();
		key.setId(id);
		int rows = getSqlMapClientTemplate().delete("TBL_OA_DESTINATION.deleteById",key);
		return rows;
	}

	public void insert(TblDestination dest) {
		getSqlMapClientTemplate().insert("TBL_OA_DESTINATION.insert",dest);
		
		
	}

	public int updateById(TblDestination dest) {
		int rows = getSqlMapClientTemplate().update("TBL_OA_DESTINATION.updateById", dest);
		return rows;
		
		
	}

	public int updateByStatus(TblDestination dest) {
		int rows = getSqlMapClientTemplate().update("TBL_OA_DESTINATION.updateByStatus", dest);
		return rows;
		
	}


	public int selectCount(String city,String area,String address,String areaname,String siteid,String status) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("siteid", siteid);
		map.put("city",city);
		map.put("area", area);
		map.put("address", address);
		map.put("areaname", areaname);
		map.put("status", status);
		int count = (Integer)getSqlMapClientTemplate().queryForObject("TBL_OA_DESTINATION.selectCount",map);
		return count;
	}

	@Override
	public List<TblDestination> selectDestin(int begin, int pageSize, String orderByField, String orderByMode,
			String city, String area, String address, String areaname, String siteid,String status) {
		Map<String, Object> map = new HashMap<String, Object>();
		int end = begin + pageSize;
		begin = begin + 1;
		map.put("begin", begin);
		map.put("end", end);
		map.put("orderByField", orderByField);
		map.put("orderByMode", orderByMode);
		map.put("siteid", siteid);
		map.put("city",city);
		map.put("area", area);
		map.put("address", address);
		map.put("areaname", areaname);
		map.put("status", status);
		List<TblDestination> list = getSqlMapClientTemplate().queryForList("TBL_OA_DESTINATION.selectDestin",map);
		return list;
	}
	@Override
	public int updateByAllStatus(TblDestination dest) {
		int rows = getSqlMapClientTemplate().update("TBL_OA_DESTINATION.updateByAllStatus", dest);
		return rows;
	}


	
}
